package com.daiqee.controller;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.daiqee.controller.support.CommonsController;
import com.daiqee.pojo.SupplierArrears;
import com.daiqee.service.impl.SupplierArrearsService;

/**
 * 供应商欠款
 * 
 * <br/>
 * @since JDK 1.8
 * @version  V2.1
 * @author RichardTang 
 * @date: 2018年5月7日 下午5:56:42
 * @package com.daiqee.handler
 * @copyright:Copyright (c) 2018, 1245811923@qq.com All Rights Reserved.
 */
@Controller
@RequestMapping("financial/supplier-arrears")
public class SupplierArrearController extends CommonsController<SupplierArrears>{

	@Autowired
	private SupplierArrearsService supplierArrearsService;
	
	@Override
	public boolean warpperAddMethod(SupplierArrears supplierArrears) throws Exception {
		supplierArrears.setSupArreSum(supplierArrears.getSupArreSum());
		return supplierArrearsService.insert(supplierArrears);
	}
	
	@Override
	public boolean warpperUpdateMethod(SupplierArrears supplierArrears) {
		supplierArrears.setSupArreSum(supplierArrears.getSupArreSum());
		return supplierArrearsService.updateById(supplierArrears);
	}
	
	/**
	 * 查询数据库欠款中是否存在该供应商
	 * 
	 * @param supplierName
	 * 				供应商名称
	 * 
	 * @return restful风格 Http状态码 Void
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping(value="/exist",method=RequestMethod.GET)
	public Object queryIsSupplier(String supplierName) throws UnsupportedEncodingException{
		String param = new String(supplierName.getBytes("ISO8859-1"), "UTF-8");
		return supplierArrearsService.querySupplierIsExist(param);
	}
}
